package com.xt.purchasingsystem.utils;

import java.util.List;

/**
 * oracle数据库分页工具类
 */
public class PageBean {
    private int pageSize;//页码大小
    private int currNo;//当前页码
    private int rowCount;//总行数
    private int pageCount;//总页数
    private List pageList;//页面显示的数据集合

    public PageBean(int pageSize, int currNo, int rowCount) {
        this.pageSize = pageSize;
        this.currNo = currNo;
        this.rowCount = rowCount;
        //求出总页数
        if (this.rowCount % this.pageSize == 0) {
            this.pageCount = this.rowCount / this.pageSize;
        } else {
            this.pageCount = this.rowCount / this.pageSize + 1;
        }
		//判断是否达到最后一页
        //当前页码小于
        if (this.currNo > this.pageCount) this.currNo = this.pageCount;
        if (this.currNo < 1) this.currNo = 1;
    }


    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCurrNo() {
        return currNo;
    }

    public void setCurrNo(int currNo) {
        this.currNo = currNo;
    }

    public int getRowCount() {
        return rowCount;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public List getPageList() {
        return pageList;
    }

    public void setPageList(List pageList) {
        this.pageList = pageList;
    }

    //获取开始下标
    public int getStart() {
		return (this.currNo - 1) * this.pageSize+1;
    }
	//获取结束下标
	public int getEnd() {
		return this.currNo  * this.pageSize;
	}



}
